package com.ebo.synframework.synroom.config;

import java.io.InputStream;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class PoolConfig {
    private String name;
    
    private int poolNum;
    
    private int minThreadNum;
    
    private int maxThreadNum;
    
    private int queueTaskNum;
    
    public PoolConfig(String xmlUrl) {
        try {
            InputStream is = PoolConfig.class.getClassLoader().getResourceAsStream(xmlUrl);
            SAXReader reader = new SAXReader();
            Document document = reader.read(is);
            Element rootEle = document.getRootElement();
            this.name = rootEle.elementText("Name");
            this.poolNum = Integer.parseInt(rootEle.elementText("PoolNum"));
            this.minThreadNum = Integer.parseInt(rootEle.elementText("MinThreadNum"));
            this.maxThreadNum = Integer.parseInt(rootEle.elementText("MaxThreadNum"));
            this.queueTaskNum = Integer.parseInt(rootEle.elementText("QueueTaskNum"));
        } catch (Exception e) {
            throw new Error("init pool config fail", e);
        }
    }

    public String getName() {
        return name;
    }

    public int getPoolNum() {
        return poolNum;
    }

    public int getMinThreadNum() {
        return minThreadNum;
    }

    public int getMaxThreadNum() {
        return maxThreadNum;
    }

    public int getQueueTaskNum() {
        return queueTaskNum;
    }

    public void setQueueTaskNum(int queueTaskNum) {
        this.queueTaskNum = queueTaskNum;
    }

}
